//
//  SendWeiboImage.m
//  share
//
//  Created by Kongho Poon on 15/3/11.
//  Copyright (c) 2015年 Jxtech. All rights reserved.
//

#import "SendWeiboImage.h"

@implementation SendWeiboImage

- (id)initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    NSArray *nib =[[NSBundle mainBundle] loadNibNamed:@"SendWeiboImage" owner:self options:nil];
    self = [nib objectAtIndex:0];
  }
  
  return self;
}

- (void)setImage:(UIImage *)image {
  _image = image;
  
  if (image == nil) {
    self.deleteBtn.hidden = YES;
    self.clickBtn.hidden = NO;
    self.imageView.image = [UIImage imageNamed:@"become_expert_upload_bg"];
  } else {
    self.deleteBtn.hidden = NO;
    self.clickBtn.hidden = YES;
    self.imageView.image = image;
  }
}

- (IBAction)touchDelete:(id)sender {
  if (self.delegate && [self.delegate respondsToSelector:@selector(sendWeiboImage:deleteAtIndex:type:)]){
    [self.delegate sendWeiboImage:self deleteAtIndex:self.index type:self.type];
  }
}

- (IBAction)touchClick:(id)sender {
  if (self.delegate && [self.delegate respondsToSelector:@selector(clickToAddImageWithType:)]) {
    [self.delegate clickToAddImageWithType:self.type];
  }
}

@end
